﻿using Leo.Awesome.AppPlatform.Localization;
using Leo.Cloud.IdentityLogin;
using Volo.Abp.Identity;
using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem;

namespace Leo.Awesome.AppPlatform;

[DependsOn(
    typeof(AbpPermissionManagementDomainSharedModule),
    typeof(AbpIdentityDomainSharedModule),
    typeof(IdentityLoginDomainSharedModule)
    )]
public class AppPlatformDomainSharedModule : AbpModule
{
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        AppPlatformGlobalFeatureConfigurator.Configure();
        AppPlatformModuleExtensionConfigurator.Configure();
    }

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        Configure<AbpVirtualFileSystemOptions>(options =>
        {
            options.FileSets.AddEmbedded<AppPlatformDomainSharedModule>();
        });

        Configure<AbpLocalizationOptions>(options =>
        {
            options.Resources
                .Add<AppPlatformResource>("en")
                .AddBaseTypes(typeof(AbpValidationResource))
                .AddVirtualJson("/Localization/AppPlatform");

            options.DefaultResourceType = typeof(AppPlatformResource);
        });

        Configure<AbpExceptionLocalizationOptions>(options =>
        {
            options.MapCodeNamespace("AppPlatform", typeof(AppPlatformResource));
        });
    }
}
